/**
 * 时间的显示样式
 * 0 xx时xx分xx秒   1 xx:xx:xx: 
 */
export enum TimeDisplayType{
    FONT,
    POINT,
}
/**
 * 时间的更新方式
 * 0 递减 
 * 1 递增 
 */
export enum TimeUpdateType{
    SUB,
    ADD,
}

export default class TimeDisplay  {

    /**
     * 
     * @param t 时间 秒
     * @param type 时间的显示类型 0 xx时xx分xx秒   1 xx:xx:xx: 
     */
    static getTimeString(t:number,type:TimeDisplayType = TimeDisplayType.FONT):string{
        if(!t || t === 0){
            return "00:00:00";
        }
        let time = t;
        // cc.log(" time ",this.time);
        let display:string = "";

        let s = time % 60;

        let m = Math.floor(time/60%60);

        let h = Math.floor(time/3600%24);

        let d = Math.floor(time/3600/24);
        let ss:string = ""+s;
        if(s < 10){
            ss = "0"+ss;
        }
        let mm = ""+m;
        if(m < 10){
            mm = "0"+mm;
        } 
        let hh = ""+h;
        if(h < 10){
            hh = "0"+hh;
        }   
        let dName = "d"
        let hName = "h"
        let mName = 'm'
        let sName = 's'

        if(d > 0){
            display =  d+dName+hh+hName+mm+mName;
        }else{
            if(type == TimeDisplayType.FONT){
                if(h != 0 ){
                    display = hh+hName+mm+mName+ss+sName;
                }else if(m != 0){
                    display = mm+mName+ss+sName;
                }else{
                    display = ss+sName;
                }
            }else{
                if(h != 0 ){
                    display = hh+":"+mm+":"+ss;
                }else if(m != 0){
                    display = mm+":"+ss;
                }else{
                    display = ss;
                } 
            }

           
        }
        return display;
    }  
}
